//
//  CLCellBookSheif.m
//  CLBrowser
//
//  Created by 梁慧聪 on 2022/5/7.
//

#import "CLCellBookSheif.h"
#import "CLBook.h"
@implementation CLCellBookSheif
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubViews];
    }
    return self;
}

- (void)configSubViews {
    self.ivLogo = ({
        UIImageView *view = [[UIImageView alloc]init];
        [self.contentView addSubview:view];
        view.backgroundColor = [UIColor lightGrayColor];
        view;
    });
    
    self.lbTitle = ({
        UILabel *view = [[UILabel alloc]init];
        [self.contentView addSubview:view];
        view.font = [UIFont systemFontOfSize:12];
        view.numberOfLines = 2;
        view;
    });
    
    [self.ivLogo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.contentView);
        make.height.mas_equalTo(self.ivLogo.mas_width).multipliedBy(115/98.0);
    }];
    
    [self.lbTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.contentView);
        make.top.equalTo(self.ivLogo.mas_bottom);
    }];
}

- (void)collectionView:(ChuckCollectionView *)collectionView vcDelegate:(id)vcDelegate cellForRowWithModel:(CLBook *)book atIndexPath:(NSIndexPath *)indexPath {
    [self.ivLogo sd_setImageWithURL:[NSURL URLWithString:book.logo]];
    self.lbTitle.text = book.title;
}
@end
